package com.letv.work.leso;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Static method class
 * listen and take notes on leso job run state.
 */
public class ListenLesoJob {

    /**
     * Logger
     */
    private final static Logger LOGGER = LoggerFactory.getLogger(ListenLesoJob.class);

    /**
     * boolean, run    -- true
     *          finish -- false
     */
    private static boolean FLAG = false;

    /**
     * set flag : leso offlinetask job is running
     */
    public static void setLesoIsRuning() {
        try {
            ListenLesoJob.FLAG = true;
            LOGGER.info("leso offlinetask job is running,flag set true");
        } catch(Exception e) {
            LOGGER.error("error to set flag true for leso job running", e);
        }
    }

    /**
     * set flag : leso offlinetask job is finished
     */
    public static void setLesoIsFinished() {
        try {
            ListenLesoJob.FLAG = false;
            LOGGER.info("leso offlinetask job is finished,flag set false");
        } catch(Exception e) {
            LOGGER.error("error to set flag false for leso job finished", e);
        }
    }

    /**
     * get leso job run state
     * @return boolean
     *                true  -- run
     *                false -- not run
     */
    public static boolean lesoJobIfRun() {
        return ListenLesoJob.FLAG;
    }
}
